docs: Fix Flutter client imports, client exception example, and the real-time tutorial for 4.0 - #806
Conversation
| } on ServerpodClientHttpException catch (e) { | ||
| // The server returned an error, for example a 500. | ||
| showError('Something went wrong (${e.statusCode}). Please try again.'); | ||
| } |
There was a problem hiding this comment.
Suggestion: line 204 says to fall back to the general case, but the last clause here is a specific one now. Adding the catch-all back also re-covers ServerpodClientUnknownException, which the previous on ServerpodClientException caught.
| } on ServerpodClientHttpException catch (e) { | |
| // The server returned an error, for example a 500. | |
| showError('Something went wrong (${e.statusCode}). Please try again.'); | |
| } | |
| } on ServerpodClientHttpException catch (e) { | |
| // The server returned an error, for example a 500. | |
| showError('Something went wrong (${e.statusCode}). Please try again.'); | |
| } on ServerpodClientException catch (_) { | |
| // Anything else the client could not classify. | |
| showError('Something went wrong. Please try again.'); | |
| } |
|
|
||
| client = Client(serverUrl) | ||
| Future<void> initializeClient() async { | ||
| client = Client(await getServerUrl()) |
There was a problem hiding this comment.
Suggestion: the template has a top-level final serverUrl = getServerUrl(); and then Client(await serverUrl), which is also the form the other pages in this PR use. The getServerUrl() explanation below still reads fine, since serverUrl is that call's result.
| client = Client(await getServerUrl()) | |
| client = Client(await serverUrl) |
| @@ -197,8 +197,10 @@ fields: | |||
| A call from the client can fail in three ways, and you usually handle each one differently: | |||
There was a problem hiding this comment.
Suggestion: with the catch-all added back, the list runs to four: a serializable exception, ServerpodClientHttpException, ServerpodClientNetworkException, and whatever ServerpodClientException catches last.
| A call from the client can fail in three ways, and you usually handle each one differently: | |
| A call from the client can fail in a few ways, and you usually handle each one differently: |
client.dart(docs: Flutter snippets import client from main.dart, which no longer exports it #794): rc.2 moved client setup out ofmain.dartintolib/client.dartwith aninitializeClient()thatmain()awaits (refactor: Extract client setup into client.dart in template serverpod#5658). Snippets that importedclientfrommain.dartno longer compiled. Fixed in the build-your-first-app pages, working-with-endpoints, the project tree, and the Pixorama tutorial.initialize*SignIn()inmain()afterclient.auth.initialize(); that call is now ininitializeClient(). Updated the instructions and snippets, plus the related Google troubleshooting and customizations notes and the legacy-auth migration guide.ServerpodClientExceptionis sealed with onlymessage, so thestatusCode == -1example did not compile. The page now describesServerpodClientHttpException(withServerpodClientUnknownHttpExceptionfor unmapped codes such as 413) andServerpodClientNetworkException, and the example catches those. Also updated the quoted error in the Google troubleshooting page, sincetoString()prints the runtime type.--miniand the Mini guide are gone. The tutorial now creates the project with the database deselected, removes the template'sgreetingsfeature instead of a non-existentexample.spy.yaml, and uses one runningserverpod startinstead of twoserverpod generatesteps. Thecreatereference intro no longer advertises--template mini.Markdownlint passes on all changed files except for nine pre-existing findings on the Facebook setup page, outside the edited section.
Fixes #794, fixes #795, fixes #797.